#include "../BSP/uart.h"

#define DEMCR (*(unsigned int *)0xE000EDFC)
#define TRCENA (0x01 << 24)
#define DWT_CTRL (*(unsigned int *)0xE0001000)
#define CYCCNTENA (0x01 << 0)
#define DWT_CYCCNT (*(volatile unsigned int *)0xE0001004)

void BSP_Rand_Init() {
  DEMCR |= TRCENA;
  DWT_CTRL |= CYCCNTENA;
}

uint8_t BSP_Rand_Get(uint8_t value) { return (DWT_CYCCNT) % value; }
